<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,user-scalable=0"
    />
    <link rel="manifest" href="./manifest.json" />
    <meta name="theme-color" content="#2d8cf0" />
    <!-- 针对safari（iOS）的添加到桌面功能进行相关设置 -->
    <!-- app名称 -->
    <meta name="apple-mobile-web-app-title" content="wap测试" />
    <!-- 是否隐藏地址栏等 -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- 状态栏颜色 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="default" />
    <!-- 指定桌面icon -->
    <link
      rel="apple-touch-icon"
      href="./img/icons/apple-touch-icon-76x76.png"
    />
    <!--end-->
    <!-- IE的设置 -->
    <meta name="application-name" content="wap测试" />
    <meta name="msapplication-TileColor" content="#222" />
    <meta
      name="msapplication-square70x70logo"
      content="./img/icons/apple-touch-icon-76x76.png"
    />
    <meta
      name="msapplication-square150x150logo"
      content="./img/icons/apple-touch-icon-152x152.png"
    />
    <meta
      name="msapplication-square310x310logo"
      content="./img/icons/apple-touch-icon-152x152.png"
    />
    <!--end-->
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
    <script>
      // 判断浏览器是否支持 service worker
      if ('serviceWorker' in navigator) {
        // load 事件完成之后才注册 service worker
        window.addEventListener('load', function () {
          console.log('1等待5分钟')
          console.log('2判断当前用户弹出对话框的次数是否达到2次')
          console.log('2.1未达到2次,弹出创建快捷方式对话框')
          console.log('2.1.1用户确认创建快捷方式继续执行【注册sw.js】')
          console.log('2.1.2用于取消不继续执行')
          console.log('2.1.3当前用户弹出对话框的次数+1')
          console.log('2.2达到2次不操作')
          // 注册sw.js
          // 注册sw.js 开始
          navigator.serviceWorker
            .register('/sw.js')
            .then(function (registration) {
              // 注册成功
              console.log('sw.js 注册成功', registration.scope)
            })
            .catch(function (err) {
              // 注册失败:(
              console.log('sw.js 注册失败 ', err)
            })
          // 注册sw.js结束
        })
      }
    </script>
  </body>
</html>
